<?xml version="1.0" encoding="UTF-8"?>

<xs:schema id="schema.sc2"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://a42.vodafone.com/versions/sc2/v1"
    xmlns:a42ns="http://a42.vodafone.com/versions/a42/v1"
    xmlns:sc2ns="http://a42.vodafone.com/versions/sc2/v1"
    elementFormDefault="qualified"
    >
    
    <!-- Import the common types for A42 resources. -->
    <!-- <xs:include schemaLocation="a42.xsd" /> -->
    <xs:import schemaLocation="a42.xsd" namespace="http://a42.vodafone.com/versions/a42/v1" />
    
        <xs:defaultOpenContent mode="interleave">
        <xs:any namespace="##any" processContents="lax" />
        </xs:defaultOpenContent>
    
    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    <!-- Definition of XML representations for shop catalog resources and related DTOs. -->
    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    
    <!-- Specific link types with defined link relation types. -->
    <xs:complexType name="ContentProvidersLinkType">
        <xs:complexContent>
            <xs:restriction base="a42ns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/contentProviders" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="ContentProviderLinkType">
        <xs:complexContent>
            <xs:restriction base="a42ns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/contentProvider" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="CategoriesLinkType">
        <xs:complexContent>
            <xs:restriction base="a42ns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/categories" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="CategoryLinkType">
        <xs:complexContent>
            <xs:restriction base="a42ns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/category" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="CatalogItemsLinkType">
        <xs:complexContent>
            <xs:restriction base="a42ns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/catalogItems" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="CatalogItemLinkType">
        <xs:complexContent>
            <xs:restriction base="a42ns:LinkType">
                <xs:attribute name="rel" type="xs:string" use="required"
                    fixed="http://a42.vodafone.com/rels/simpleContentCatalog/catalogItem" />
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    
    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    
    <!-- Representation for the service document for this API. -->
    <xs:element name="sc2ServiceDocument">
        <xs:complexType>
            <xs:all>
                <xs:element name="contentProvidersRootLink" type="sc2ns:ContentProvidersLinkType" />
                <xs:element name="categoriesRootLink" type="sc2ns:CategoriesLinkType" />
            </xs:all>
        </xs:complexType>
    </xs:element>
    
    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    
    <!-- Representation for a collection resource that aggregates content provider entities. -->
    <xs:element name="contentProviders" type="sc2ns:ContentProvidersType" />
    <xs:complexType name="ContentProvidersType">
        <xs:complexContent>
            <xs:extension base="a42ns:PaginatableResourceType">
                <xs:all>
                    <xs:element name="contentProviders" minOccurs="1" maxOccurs="1">
                        <xs:complexType>
                            <xs:choice minOccurs="0" maxOccurs="unbounded">
                                <xs:element name="link" type="sc2ns:ContentProviderLinkType" />
                                <xs:element name="contentProvider" type="sc2ns:ContentProviderType" />
                            </xs:choice>
                        </xs:complexType>
                    </xs:element>
                </xs:all>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
    <!-- Representation for a collection resource that aggregates category entities. -->
    <xs:element name="categories" type="sc2ns:CategoriesType" />
    <xs:complexType name="CategoriesType">
        <xs:complexContent>
            <xs:extension base="a42ns:PaginatableResourceType">
                <xs:all>
                    <xs:element name="categories" minOccurs="1" maxOccurs="1">
                        <xs:complexType>
                            <xs:choice minOccurs="0" maxOccurs="unbounded">
                                <xs:element name="link" type="sc2ns:CategoryLinkType" />
                                <xs:element name="category" type="sc2ns:CategoryType" />
                            </xs:choice>
                        </xs:complexType>
                    </xs:element>
                </xs:all>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
    <!-- Representation for a collection resource that aggregates catalog item entities. -->
    <xs:element name="catalogItems" type="sc2ns:CatalogItemsType" />
    <xs:complexType name="CatalogItemsType">
        <xs:complexContent>
            <xs:extension base="a42ns:PaginatableResourceType">
                <xs:all>
                    <xs:element name="catalogItems" minOccurs="1" maxOccurs="1">
                        <xs:complexType>
                            <xs:choice minOccurs="0" maxOccurs="unbounded">
                                <xs:element name="link" type="sc2ns:CatalogItemLinkType" />
                                <xs:element name="catalogItem" type="sc2ns:CatalogItemType" />
                            </xs:choice>
                        </xs:complexType>
                    </xs:element>
                </xs:all>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    
    <xs:complexType name="embeddedContentProviderType">
        <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="link" type="sc2ns:ContentProviderLinkType" />
            <xs:element name="contentProvider" type="sc2ns:ContentProviderType" />
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="embeddedCategoriesType">
        <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="link" type="sc2ns:CategoriesLinkType" />
            <xs:element name="categories" type="sc2ns:CategoriesType" />
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="embeddedCategoryType">
        <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="link" type="sc2ns:CategoryLinkType" />
            <xs:element name="category" type="sc2ns:CategoryType" />
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="embeddedCatalogItemsType">
        <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="link" type="sc2ns:CatalogItemsLinkType" />
            <xs:element name="catalogItems" type="sc2ns:CatalogItemsType" />
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="embeddedCatalogItemType">
        <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="link" type="sc2ns:CatalogItemLinkType" />
            <xs:element name="catalogItem" type="sc2ns:CatalogItemType" />
        </xs:choice>
    </xs:complexType>
    
    <!-- Representation for a content provider resource. -->
    <xs:element name="contentProvider" type="sc2ns:ContentProviderType" />
    <xs:complexType name="ContentProviderType">
        <xs:complexContent>
            <xs:extension base="a42ns:ResourceType">
                <xs:all>
                    <xs:element name="catalogItems" type="sc2ns:embeddedCatalogItemsType" minOccurs="0" maxOccurs="1"/>
                    <!-- The name of the content provider. -->
                    <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- An external ID, if applicable. To be used for search queries. -->
                    <xs:element name="partnerId" type="xs:string" minOccurs="0" maxOccurs="1" />
                </xs:all>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
    <!-- Representation for a category resource. -->
    <xs:element name="category" type="sc2ns:CategoryType" />
    <xs:complexType name="CategoryType">
        <xs:complexContent>
            <xs:extension base="a42ns:ResourceType">
                <xs:all>
                    <!-- Link to the parent item, will not appear in case it is a top-level category. -->
                    <xs:element name="parentCategory" type="sc2ns:embeddedCategoryType" minOccurs="0" maxOccurs="1" />
                    <!-- Link to sub-categories, if applicable. -->
                    <xs:element name="subCategories" type="sc2ns:embeddedCategoriesType" minOccurs="0" maxOccurs="1" />
                    <!-- Link to catalog items within this category. -->
                    <xs:element name="catalogItems" type="sc2ns:embeddedCatalogItemsType" minOccurs="0" maxOccurs="1" />
                    <!-- The name of the category. -->
                    <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- An external ID, if applicable. To be used for search queries. -->
                    <xs:element name="externalId" type="xs:string" minOccurs="0" maxOccurs="1" />
                </xs:all>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- Representation for a catalog item resource. -->
    <xs:element name="catalogItem" type="sc2ns:CatalogItemType" />
    <xs:complexType name="CatalogItemType">
        <xs:complexContent>
            <xs:extension base="a42ns:ResourceType">
                <xs:all>
                    <!-- The content provider of the item. -->
                    <xs:element name="contentProvider" type="sc2ns:embeddedContentProviderType" minOccurs="0" maxOccurs="1" />
                    <!-- The category of the item. -->
                    <xs:element name="parentCategory" type="sc2ns:embeddedCategoryType" minOccurs="0" maxOccurs="1" />
                    <!-- Link to the parent item, will not appear in case it is a top-level item. -->
                    <xs:element name="parentItem" type="sc2ns:embeddedCatalogItemType" minOccurs="0" maxOccurs="1" />
                    <!-- Link to sub-items, if applicable. -->
                    <xs:element name="subItems" type="sc2ns:embeddedCatalogItemsType" minOccurs="0" maxOccurs="1" />
                    <!-- The name of the item. -->
                    <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- A description for the item. -->
                    <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- An external ID, if applicable. To be used for search queries. -->
                    <xs:element name="externalId" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- Type of the product, e.g. app, game, virtual good, music, etc. -->
                    <xs:element name="type" type="xs:string" minOccurs="0" maxOccurs="1" />
                    <!-- Flag that sets a catalog item active or inactive. It can also decouple creation from activation. -->
                    <xs:element name="isActive" type="xs:boolean" minOccurs="0" maxOccurs="1" />
                    <!-- When was (will) this item (be) released. In addition to "createdAt", can decouple creation from activation. -->
                    <xs:element name="releasedAt" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
                    <!-- Provides information about a certain age that needs to be proven to access a product. -->
                    <xs:element name="grade" type="xs:unsignedByte" minOccurs="0" maxOccurs="1" />
                    <!-- Even more details as a collection of (key, value) pairs. -->
                    <xs:element name="details" type="a42ns:KeyValueCollectionType" minOccurs="0" maxOccurs="1" />
                </xs:all>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    
</xs:schema>
